﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Kaidou.Persister;
using Kaidou.Model;
using System.Collections.Generic;
using Kaidou.Util;
using Kaidou.Bll;

public partial class master_master_trader_update_conf : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        LoginModel loginModel = (LoginModel)Session["loginModel"];

        if (loginModel == null)
        {
            Response.Redirect("../login.aspx");
        }
        else if (!loginModel.isOperator())
        {
            Response.Redirect("../menu.aspx");
        }

        string area = Resources.Resource.area;
        string[] areaArray = area.Split(',');

        MstTrader model = (MstTrader)Session["trader"];

        MST_UnionPersister dao1 = new MST_UnionPersister();
        MST_Union_BranchPersister dao2 = new MST_Union_BranchPersister();

        union_code.Text = model.UnionCode + " " + dao1.getDetail(model.UnionCode).OfficeName;
        if (model.BranchCode == 0)
        {
            branch_code.Text = "000 " + "本店";

        }
        else
        {
            branch_code.Text = StringUtil.getBranchCodeNumberFormat( model.BranchCode) + " " + dao2.getDetail(model.UnionCode, model.BranchCode).officename;
        }
        trader_reg_no.Text = model.TraderRegNo;
        trader_name.Text = model.TraderName;
        trader_kana.Text = model.TraderKana;
        trader_zip_no.Text = model.TraderZipNo;
        trader_pref_code.Text = areaArray[model.TraderPrefCode - 1];
        trader_city.Text = model.TraderCity;
        trader_address.Text = model.TraderAddress;
        trader_tel.Text = model.TraderTel;
        daihyo_name.Text = model.DaihyoName;
        daihyo_kana.Text = model.DaihyoKana;
    }

    protected void update_confirm(object sender, EventArgs e)
    {
        MST_TraderPersister dao = new MST_TraderPersister();
        MstTrader M = (MstTrader)Session["trader"];
        try
        {
            dao.updateTrader(M);
        }
        catch(Exception ee)
        {
            LogManager.error("master_master_union_update_conf - update_confirm "+ee.Message);
        }
        Session["back"] = 1;
        Response.Redirect("master_trader_search.aspx");

    }
}
